package ${groupId}.swagger.ctrl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import ${groupId}.common.Page;
import ${groupId}.mapper.*;
import ${groupId}.model.*;

import io.swagger.annotations.Api;


@Api
@RestController
@RequestMapping("/swagger/")
public class SwaggerTestCtrl {
	<#list tables as t>
	@Autowired
	private ${t.upperFirstLetterName}Mapper ${t.lowerFirstLetterName}Mapper;
	</#list>
	
	<#list tables as t>
	@RequestMapping("/get${t.upperFirstLetterName}Page/{page}")
	public Page<${t.upperFirstLetterName}> get${t.upperFirstLetterName}Page(@PathVariable("page") int pageIndex){
		int totalSize = ${t.lowerFirstLetterName}Mapper.count();
		pageIndex = pageIndex <= 0 ? 1 : pageIndex;
		int start = (pageIndex - 1) * Page.DEFAULT_PAGE_SIZE;
		return new Page<>(start, totalSize, Page.DEFAULT_PAGE_SIZE, ${t.lowerFirstLetterName}Mapper.page(start, Page.DEFAULT_PAGE_SIZE));
	}
	
	</#list>
	
}
